package BanyuanClub.Study.Day0304;

import java.io.*;

public class CarObjectSerialize {
    public static void main(String[] args) {
        try(ObjectOutputStream oos = new ObjectOutputStream(
                new FileOutputStream("car.txt"));
            ObjectInputStream ois = new ObjectInputStream(
                    new FileInputStream("car.txt"))
        ){

            Car c = new Car("benchi",20);
            oos.writeObject(c);
            Car c1 = (Car) ois.readObject();

        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
    }
}
